package com.example.houselease.preload;

import com.example.houselease.service.IAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 缓存预热
 * 项目一启动就会执行run方法
 * @author sf
 * @version 0.0.1
 * */
@Slf4j
@Component
public class CachePreload implements ApplicationRunner {

    @Autowired
    IAdminService adminService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.debug("开始执行CachePreload.run()");
        adminService.rebuildCache();
    }
}
